﻿using SD.App.Desktop.Entity;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SD.App.Desktop.Repository
{
    public class ResetPasswordTokenRepository : BaseRepository<ResetPasswordToken, long>, IResetPasswordTokenRepository
    {
        public ResetPasswordTokenRepository(SqlSugarContext sqlSugarContext, ILogger logger)
            : base(sqlSugarContext, logger)
        {
        }

        public async Task<ResetPasswordToken?> GetByUsernameAndTokenAsync(string username, string token)
        {
            return await GetFirstAsync(t => t.Username == username && t.Token == token && !t.IsUsed && t.ExpireTime > DateTime.Now);
        }
    }
}
